package javapop.framework;

public class ParsePosition implements Comparable<ParsePosition> {
	private int pos;
	private int charPos;
	private int linePos;
	
	public ParsePosition(int pos, int charPos, int linePos) {
		this.pos = pos;
		this.charPos = charPos;
		this.linePos = linePos;
	}

	public int getPos() {
		return pos;
	}

	public int getCharPos() {
		return charPos;
	}

	public int getLinePos() {
		return linePos;
	}

	@Override
	public int compareTo(ParsePosition o) {
		if(o.pos<pos)
			return -1;
		else if(o.pos>pos)
			return 1;
		else
			return 0;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj==null) return false;
		if(obj==this) return true;
		if(obj.getClass()!=this.getClass())
			return false;
		return ((ParsePosition) obj).pos == pos;
	}
	
	
	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("ParsePos[pos=");
		buf.append(pos);
		buf.append(",charPos=");
		buf.append(charPos);
		buf.append(",linePos=");
		buf.append(linePos);
		buf.append("]");
		return buf.toString();
	}
	
}
